package org.begincode.admin.service;

import com.begincode.common.constant.Constant;
import org.begincode.core.mapper.CourseLabelMapper;
import org.begincode.core.mapper.CourseLevelMapper;
import org.begincode.core.mapper.CourseMapper;
import org.begincode.core.mapper.CourseTypeMapper;
import org.begincode.core.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CourseService {
	
	private Logger logger = LoggerFactory.getLogger(CourseService.class);

	@Resource
	private CourseMapper courseMapper;
	@Resource
	private CourseLevelMapper courseLevelMapper;
	@Resource
	private CourseTypeMapper courseTypeMapper;
	@Resource
	private CourseLabelMapper courseLabelMapper;

	public int addCourse(Course course){
		return courseMapper.insertSelective(course);
	}

	public List<Course> selCourse(){
		CourseExample courseExample = new CourseExample();
		courseExample.createCriteria().andDeleteFlagEqualTo(Constant.NO_DEL_FLAG);
		return courseMapper.selectByExample(courseExample);
	}

	public List<CourseLabel> selCourseLabels(){
		CourseLabelExample courseLabelExample = new CourseLabelExample();
		courseLabelExample.createCriteria().andDeleteFlagEqualTo(Constant.NO_DEL_FLAG);
		return courseLabelMapper.selectByExample(courseLabelExample);
	}

	public List<CourseLevel> selCourseLevels(){
		CourseLevelExample courseLevelExample = new CourseLevelExample();
		courseLevelExample.createCriteria().andDeleteFlagEqualTo(Constant.NO_DEL_FLAG);
		return courseLevelMapper.selectByExample(courseLevelExample);
	}

	public List<CourseType> selCourseTypes(){
		CourseTypeExample courseTypeExample = new CourseTypeExample();
		courseTypeExample.createCriteria().andDeleteFlagEqualTo(Constant.NO_DEL_FLAG);
		return courseTypeMapper.selectByExample(courseTypeExample);
	}

}
